import { E_ADD_COURSE_USER_SOURCE, E_COURSE_OPERATION, E_COURSE_STATUS, E_EDUCATION_MODE } from '../enum/service-enum'
import { IDataWithError } from '../service-typing'

export interface ICreateCourseParam {
  userId: number
  title: string
  summary: string
  educationMethod: E_EDUCATION_MODE
  duration: number
  count: number
  charge: number
  coverUrl: string
  operation: E_COURSE_OPERATION
}

export interface ICourseInfo {
  userId: number
  courseId: number
  title: string
  summary: string
  educationMethod: E_EDUCATION_MODE
  duration: number
  count: number
  charge: number
  status: E_COURSE_STATUS
  coverUrl: string
  allowPlayback: number
  playbackExpiryDate: number
}

export interface ISetCoursePlaybackParam {
  userId: number
  courseId: number
  allowPlayback: number
  playbackExpiryDate: number
}

export interface IUpdateCourseStatusParam {
  userId: number
  courseId: number
  allowPlayback: number
  playbackExpiryDate: number
}

export interface IGetCourseInfoParam {
  userId: number
  courseId: number
}

export interface IAddCourseUserParam {
  userId: number
  courseId: number
  courseUser: {
    mobile: string
    name: string
    source: E_ADD_COURSE_USER_SOURCE
  }
}

export interface ICourseUserInfo {
  courseId: number
  name: string
  mobile: string
  userId: number
  signTime: number
  countTotal: number
  countUsed: number
  ticket: string
  url: string
  source: E_ADD_COURSE_USER_SOURCE
}

export interface IListCourseUserParam {
  userId: number
  courseId: number
}

export interface IAcceptCourseUserParam {
  messageId: number
  userId: number
  accept: boolean
}

export interface ICourseService {
  createCourse(param: ICreateCourseParam): Promise<IDataWithError<ICourseInfo>>
  updateCourse(param: ICreateCourseParam): Promise<IDataWithError<ICourseInfo>>
  setCoursePlayback(param: ISetCoursePlaybackParam): Promise<IDataWithError>
  updateCourseStatus(param: IUpdateCourseStatusParam): Promise<IDataWithError>
  getCourseInfo(param: IGetCourseInfoParam): Promise<IDataWithError<ICourseInfo>>
  addCourseUser(param: IAddCourseUserParam): Promise<IDataWithError<ICourseUserInfo>>
  listCourseUser(param: IListCourseUserParam): Promise<IDataWithError<Array<ICourseUserInfo>>>
  acceptCourseUser(param: IAcceptCourseUserParam): Promise<IDataWithError>
}
